<!DOCTYPE html>
<head>
    <title>mq消息配置</title>
    <#include "/header.html">
    <link
            href="${request.contextPath}/statics/plugins/jquery-layout/jquery.layout-latest.css"
            rel="stylesheet" />
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title" style="padding: 0 20px;">
        <li class="layui-this">创建负载消息体</li>
        <li>域名解析消息体</li>
        <li>释放负载消息体</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <div class="layui-tab-item layui-show">
            <div class="form-horizontal layui-form">
                <div class="form-group">
                    <div class="col-sm-2 control-label">负载ip</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value1" placeholder="负载ip">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">被封域名</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value2" placeholder="被封域名">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">平台id</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value3" placeholder="平台id">
                    </div>
                </div>
                <div class="form-group" style="padding-left: 130px;margin-top: 40px;">
                    <div class="btn btn-primary btnSend"><i style="display: none" class="fa fa-spinner fa-spin"></i>发送</div>
                </div>
            </div>
        </div>
        <div class="layui-tab-item ">
            <div class="form-horizontal layui-form">
                <div class="form-group">
                    <div class="col-sm-2 control-label">旧负载ip信息</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value4" placeholder="旧负载ip信息">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">新负载ip信息</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value5" placeholder="新负载ip信息">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">平台id</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value6" placeholder="平台id">
                    </div>
                </div>
                <div class="form-group" style="padding-left: 130px;margin-top: 40px;">
                    <div class="btn btn-primary btnSend"><i style="display: none" class="fa fa-spinner fa-spin"></i>发送</div>
                </div>
            </div>
        </div>
        <div class="layui-tab-item ">
            <div class="form-horizontal layui-form">
                <div class="form-group">
                    <div class="col-sm-2 control-label">旧负载ip信息</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value7" placeholder="旧负载ip信息">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">新负载ip信息</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value8" placeholder="新负载ip信息">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label">平台id</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" autocomplete="off"  id="value9" placeholder="平台id">
                    </div>
                </div>
                <div class="form-group" style="padding-left: 130px;margin-top: 40px;">
                    <div class="btn btn-primary btnSend"><i style="display: none" class="fa fa-spinner fa-spin"></i>发送</div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var form = null;
    var tabId=1;
    $(function() {
        form = layui.form;
        layui.use('element', function(){
            var element = layui.element;
            element.on('tab(docDemoTabBrief)', function(data){
                tabId = data.index +1;
            });
        });

        $('.btnSend').click(function(){
            if(!$(this).attr('disabled')) {
                var _obj ={}
                if(tabId==1){
                    if(!$('#value1').val() ||!$('#value2').val()||!$('#value3').val()){
                        layer.msg('信息不能为空！');
                        return;
                    }
                    _obj = {
                        slbIp:$('#value1').val(),
                        domin:$('#value2').val(),
                        platformId:$('#value3').val()
                    }
                }else if(tabId==2){
                    if(!$('#value4').val() ||!$('#value5').val()||!$('#value6').val()){
                        layer.msg('信息不能为空！');
                        return;
                    }
                    _obj = {
                        oldIp:$('#value4').val(),
                        newIp:$('#value5').val(),
                        platformId:$('#value6').val()
                    }
                }else if(tabId==3){
                    if(!$('#value7').val() ||!$('#value8').val()||!$('#value9').val()){
                        layer.msg('信息不能为空！');
                        return;
                    }
                    _obj = {
                        oldIp:$('#value7').val(),
                        newIp:$('#value8').val(),
                        platformId:$('#value9').val()
                    }
                }
                _obj.mqType = tabId;
                $(this).attr('disabled', 'disabled').find('.fa').show();
                var _this = $(this)
                $.ajax({
                    type: "POST",
                    url: baseURL + "aliyunMqMessage/executeMqMsg",
                    contentType: "application/json",
                    data:JSON.stringify(_obj),
                    success: function (r) {
                        if(r.code==0){
                            layer.msg('发送成功')
                        }
                        _this.attr('disabled',false).find('.fa').hide()
                    },
                    error:function(){
                        _this.attr('disabled',false).find('.fa').hide()
                    }
                })
            }

        })
    })

</script>
</body>
</html>